<template>
	<view>
		<view class="header">
			<view class="title">导出订单</view>
		</view>

		<view class="content">
			<view class="card">
				<view class="card-title">订单导出链接</view>
				<view class="link-box">
					<text class="link-text">{{exportUrl}}</text>
					<view class="copy-btn" @click="copyLink">
						<text class="copy-icon">📋</text>
						<text>复制链接</text>
					</view>
				</view>
				<view class="tip">
					<text class="tip-icon">💡</text>
					<text class="tip-text">请将链接复制到电脑浏览器中下载</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as api from '@/api/staff'
	import storage from '@/utils/storage'
	
	export default {
		data() {
			return {
				activityId: 0,
				exportUrl: 'https://example.com/export/123456', // 测试链接
				loading: false,
				error: ''
			}
		},
		onLoad() {
			this.activityId = storage.get('activityId')
			this.getExportUrl()
		},
		methods: {
			getExportUrl() {
				this.loading = true
				this.error = ''
				api.getExportUrl({
					activity_id: this.activityId
				}).then(res => {
					this.exportUrl = res.data.url
				}).catch(err => {
					this.error = '获取链接失败，请稍后重试'
					uni.showToast({
						title: '获取链接失败',
						icon: 'none'
					})
				}).finally(() => {
					this.loading = false
				})
			},
			copyLink() {
				uni.setClipboardData({
					data: this.exportUrl,
					success: () => {
						uni.showToast({
							title: '复制成功',
							icon: 'success'
						})
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F6F7FB;
	}

	.header {
		background-color: #FFAC3E;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 250rpx;
		border-radius: 0rpx 0rpx 20rpx 20rpx;
	}

	.header > .title {
		color: #fff;
		padding: 30rpx;
		font-size: 40rpx;
		font-weight: bold;
	}

	.content {
		margin-top: 120rpx;
		padding: 20rpx;
		box-sizing: border-box;
		position: relative;
	}

	.card {
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 30rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	.card-title {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
		margin-bottom: 20rpx;
	}

	.link-box {
		background: #F8F8F8;
		border-radius: 10rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
	}

	.link-text {
		font-size: 28rpx;
		color: #333;
		word-break: break-all;
	}

	.copy-btn {
		margin-top: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #FFAC3E;
		color: #FFFFFF;
		padding: 15rpx 30rpx;
		border-radius: 30rpx;
		font-size: 28rpx;
	}

	.copy-icon {
		margin-right: 10rpx;
		font-size: 32rpx;
	}

	.tip {
		display: flex;
		align-items: center;
		background: #FFF8E6;
		padding: 20rpx;
		border-radius: 10rpx;
	}

	.tip-icon {
		font-size: 32rpx;
		margin-right: 10rpx;
	}

	.tip-text {
		font-size: 26rpx;
		color: #FFAC3E;
	}

	.loading, .error {
		text-align: center;
		padding: 30rpx;
		font-size: 28rpx;
		color: #666;
	}

	.error {
		color: #ff4d4f;
	}
</style> 